package com.bristua.mall.order.biz;

import com.bristua.mall.common.utils.DateUtil;
import com.bristua.mall.order.dao.TOrderMapper;
import com.bristua.mall.order.model.TOrder;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * Created by Administrator on 2019/4/29.
 */
@Service
@Transactional
public class UpdateOrderStatusBiz {
    @Resource
    private TOrderMapper tOrderMapper;

    public void updateOrderStatus(String orderId,String status){
        //status  1:转为支付成功,2:发货成功，3:确认收货成功,4:评价成功,5:取消订单
        TOrder tOrder = tOrderMapper.selectByPrimaryKey(orderId);
        switch (status){
            case "1":
                tOrder.setPayStaus("2");
                tOrder.setSendStatus("1");
                tOrder.setPayTime(DateUtil.getDateTime3());
                break;
            case "2":
                tOrder.setSendStatus("2");
                tOrder.setConfirmStatus("1");
                break;
            case "3":
                tOrder.setConfirmStatus("2");
                tOrder.setEvaluateStatus("0");
                tOrder.setConfirmTime(DateUtil.getDateTime3());
                break;
            case "4":
                tOrder.setEvaluateStatus("1");
                tOrder.setOrderStatus("3");
                break;
            case "5":
                tOrder.setOrderStatus("2");
                tOrder.setCancelTime(DateUtil.getDateTime3());
                break;
        }

        tOrderMapper.updateByPrimaryKeySelective(tOrder);
    }
}
